/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bestcoach.gui;

import bestcoach.tablemodels.AttendanceTableModel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @author Anton
 */
public class TrainingAttendanceSheetDialog extends JDialog {

    AttendanceTableModel attTableModel;
    JTable unattendedTable;
    JScrollPane scrollpane;
    JPanel panelBottom;
    JButton btnSaveAndExit;

    public TrainingAttendanceSheetDialog(Connection conn, final int id) {
        this.setTitle("Unattended Players");
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setSize(600, 650);
        this.setModal(true);
        this.setLocationRelativeTo(rootPane);
        this.setLayout(new BorderLayout());

        attTableModel = new AttendanceTableModel(conn, id);
        unattendedTable = new JTable(attTableModel);
        scrollpane = new JScrollPane(unattendedTable);

        unattendedTable.setRowHeight(20);
        
        panelBottom = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        btnSaveAndExit = new JButton(new AbstractAction("Save And Exit") {
            @Override
            public void actionPerformed(ActionEvent e) {
                attTableModel.commitChanges();
                System.out.println("trainings attendance dialog saved and disposed");
                dispose();
            }
        });

        this.add(scrollpane, BorderLayout.CENTER);
        this.add(panelBottom, BorderLayout.SOUTH);
        panelBottom.add(btnSaveAndExit);

        this.setVisible(true);
    }
}
